#include <iostream>
using namespace std;

int tmp[1010];
void mergeSort(int arr[], int left, int right)
{
	if (left >= right) return;

	int mid = (left + right) >> 1;
	mergeSort(arr, left, mid);
	mergeSort(arr, mid + 1, right);
	int cur1 = left, cur2 = mid + 1, i = 0;
	while (cur1 <= mid && cur2 <= right)
	{
		if (arr[cur1] < arr[cur2]) tmp[i++] = arr[cur1++];
		else tmp[i++] = arr[cur2++];
	}
	while (cur1 <= mid) tmp[i++] = arr[cur1++];
	while (cur2 <= right) tmp[i++] = arr[cur2++];
	for (int i = left; i <= right; i++)
		arr[i] = tmp[i - left];
}
int main()
{
	int arr[] = { 88, 22, 33, 18, 98, 34, 50, 70 };
	int len = sizeof(arr) / sizeof(arr[0]);
	mergeSort(arr, 0, len - 1);
	for (int i = 0; i < len; i++) cout << " " << arr[i];
	cout << endl;
	return 0;
}